package com.tv.enoguia.adapter;

import java.util.ArrayList;

import com.tv.enoguia.R;
import com.tv.enoguia.bean.Categories;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ListFavoritesAdapter extends ArrayAdapter<Categories> {

	Context context;
	ArrayList<Categories> categories = new ArrayList<Categories>();

	public ListFavoritesAdapter(Context context,
			ArrayList<Categories> categories) {
		super(context, R.layout.item_list_favorites, categories);
		this.context = context;
		this.categories = categories;
	}

	@Override
	public int getCount() {
		return categories.size();
	}

	@Override
	public Categories getItem(int position) {
		return categories.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		
		Holder holder = null;
		if (v==null){
			LayoutInflater inflater = LayoutInflater.from(getContext());
			v = inflater.inflate(R.layout.item_list_favorites, parent, false);
			holder = new Holder();

			
			holder.txtName = (TextView) v.findViewById(R.id.txt_name);
			
			v.setTag(holder);
		} else {
			holder = (Holder) v.getTag();
		}
		
		holder.txtName.setText(categories.get(position).getName());
		
		return v;
	}
	
	class Holder{
		TextView txtName;
	}
	
	
	

}
